<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>浏览器的本地存储</title>
</head>
<body>
<!--当前网站是那个就看的是那个网站的localStorage 只要手动不清除就一直留着-->
<button onclick="demo1()">将信息存入localStorage</button>
<button onclick="demo2()">localStorage读取信息</button>
<button onclick="demo3()">删除localStorage中的信息</button>
<button onclick="demo4()">清空localStorage中的信息</button>
<script type="text/javascript">
    const p = {name: '小李', age: 18}

    function demo1() {
        localStorage.setItem('message',JSON.stringify(p))
        localStorage.setItem('somedata','英语')
    }
    function demo2(){
        const x=localStorage.getItem('message')
        console.log(JSON.parse(x))
    }
    function demo3(){
        localStorage.removeItem('message')
    }
    function demo4(){
        localStorage.clear()
    }
</script>
</body>
</html>